<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>响应式布局</title>
  <style>
    /* .par {
      border: 5px solid #fcc;
      width: 300px;
      overflow: hidden;
    }

    .child {
      border: 5px solid #f66;
      width: 100px;
      height: 100px;
      float: left;
    } */
  </style>


</head>

<body>
  <div id="box">
    <input type="button" id="add" value="添加" />
    <input type="button" id="remove" value="删除" />
    <input type="button" id="move" value="移动" />
    <input type="button" id="select" value="选择" />
  </div>
</body>



<a href="http://caibaojian.com/" id="testA">caibaojian.com</a>
<script>

  // window.onload = function () {
  //   var Add = document.getElementById("add");
  //   var Remove = document.getElementById("remove");
  //   var Move = document.getElementById("move");
  //   var Select = document.getElementById("select");

  //   Add.onclick = function () {
  //     alert('添加');
  //   };
  //   Remove.onclick = function () {
  //     alert('删除');
  //   };
  //   Move.onclick = function () {
  //     alert('移动');
  //   };
  //   Select.onclick = function () {
  //     alert('选择');
  //   }

  // }

  // 事件委托
  window.onload = function () {
    var oBox = document.getElementById("box");
    oBox.onclick = function (ev) {
      var ev = ev || window.event;
      var target = ev.target || ev.srcElement;
      if (target.nodeName.toLocaleLowerCase() == 'input') {
        switch (target.id) {
          case 'add':
            alert('添加');
            break;
          case 'remove':
            alert('删除');
            break;
          case 'move':
            alert('移动');
            break;
          case 'select':
            alert('选择');
            break;
        }
      }
    }

  }

  var a = document.getElementById("testA");
  a.onclick = function (e) {
    console.log(e);
    console.log(e.preventDefault);
    if (e.preventDefault) {
      console.log("1");
      e.preventDefault();
    } else {
      console.log("2");
      window.event.returnValue == false;
    }
  }
</script>

</html>